package com.yupi.usercenter.once;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ImportXingQiuUser {

    public static void main(String[] args) {
        //Excel数据文件放在自己电脑上，能够找到的路径
        String fileName = "D:\\edgedownloads\\Idea\\xingxiang_back\\src\\main\\resources\\工作簿1.xlsx";
        List<UserInfor> userInfoList =
                EasyExcel.read(fileName).head(UserInfor.class).sheet().doReadSync();
        System.out.println("总数 = " + userInfoList.size());
        Map<String, List<UserInfor>> listMap =
                userInfoList.stream()
                        .filter(userInfo -> StringUtils.isNotEmpty(userInfo.getUsername()))
                        .collect(Collectors.groupingBy(UserInfor::getUsername));
        for (Map.Entry<String, List<UserInfor>> stringListEntry : listMap.entrySet()) {
            if (stringListEntry.getValue().size() > 1) {
                System.out.println("username = " + stringListEntry.getKey());
                System.out.println("1");
            }
        }
        System.out.println("不重复昵称数 = " + listMap.keySet().size());
    }
}
